<?php
/**
 * 描述：订单对象。
 */
final class Ordersheet
{
    const SESSION_NAME='shipinall_aaljfad87923&^%#@!njdz*(*&^__ordersheetdata______';

    private $Data=NULL;

    public function __construct()
    {
        if($this->Data){
            return $this->Data;
        }
        else
        {
            if($_SESSION[self::SESSION_NAME]){
                return $this->Data=$_SESSION[self::SESSION_NAME];
            }
            else{
                $this->Data=array();
            }
        }
    }

    public function __destruct()
    {
        $_SESSION[self::SESSION_NAME]=$this->Data;
    }
    
    public function Add($data)
    {
        $this->Data[$data['ID']]=$data;
    }

    public function Delete($id)
    {
        $this->Data[$id]=pop($this->Data[$id]);
    }

    public function Edit($data)
    {
        $this->Data[$data['ID']]=$data;
    }

    private static $Instance=NULL;

    public static function GetInstance()
    {
        if(self::$Instance){
            return self::$Instance;
        }
        else{
            return self::$Instance=new Ordersheet();
        }
    }

    public static function Add($id)
    {
        $ordersheet=self::GetInstance();

        #查询数据
        #单价 最小订货量 运费
        $data=get();
        $ordersheet->Add($data);
        
    }

    public static function delete($id)
    {
        $ordersheet=self::GetInstance();
        $ordersheet->Delete($id);
    }
    
    public static function edit($id)
    {
        $ordersheet=self::GetInstance();
        $data=get();
        $ordersheet->eidt($data);
    }

    public static function Data()
    {
        $ordersheet=self::GetInstance();
        return $ordersheet->GetData();
    }

    public static function settle()
    {
        
    }
}
?>